package com.kkb.shopcenter.controller;

import com.kkb.shopcenter.api.ProductInfoService;
import com.kkb.shopcenter.common.common.HttpResult;
import com.kkb.shopcenter.common.pojo.ProductInfo;
import com.kkb.shopcenter.common.pojo.ProductInfoVo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api")
public class ProductController {

    @Reference
    private ProductInfoService productInfoService;

    /**
     * 增加产品和商品
     * @param productInfoVo 产品视图包含商品和属性
     * @return
     */
    @ResponseBody
    @PostMapping("/addProduct")
    public HttpResult addProduct(@RequestBody ProductInfoVo productInfoVo){

        ProductInfo productInfo = (ProductInfo) productInfoVo;
        int result = productInfoService.addProductInfo(productInfo,
                productInfoVo.getExtrAttribute(),productInfoVo.getIntroduce());

        return HttpResult.success(result);
    }
}
